package com.caird.common.utils;

import io.netty.buffer.ByteBuf;

public class DataTypeUtils {

    /**
     * ByteBuf转HexString
     */
    public static String byteBuf2HexString(ByteBuf byteBuf) {
        int reader = byteBuf.readerIndex();
        int length = byteBuf.readableBytes();
        StringBuilder sb = new StringBuilder(length * 2);
        for (int i=0; i<length; i++) {
            sb.append(String.format("%02X", byteBuf.getUnsignedByte(reader+i)));
        }
        return sb.toString();
    }
}
